class Car:
    def __init__(self, make, model, year):
        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0

    def get_descriptive_name(self): 
        """返回格式规范的描述性信息""" 
        long_name = f"{self.year} {self.make} {self.model}" 
        return long_name.title()

    def read_odometer(self): 
        """打印一条指出汽车行驶里程的消息""" 
        print(f"This car has {self.odometer_reading} miles on it.")

    def update_odometer(self, mileage):
        """将里程表读数设置为指定的值"""
        self.odometer_reading = mileage

    def increment_odometer(self, miles):
        """将里程表读数增加指定的量"""
        self.odometer_reading += miles


my_new_car = Car('audi', 'a4', 2019)
# print(my_new_car.get_descriptive_name())
# print(my_new_car.read_odometer())

""" 9.2.3 通过实例修改属性的值 """
# my_new_car.odometer_reading = 23
# my_new_car.read_odometer()

""" 9.2.3 属性也可以通过在类内部定义的方法来更新 """
# my_new_car.update_odometer(23)
# my_new_car.read_odometer()

""" 9.2.3 通过方法递增属性的值  """
my_new_car.update_odometer(23_500)
my_new_car.read_odometer()
my_new_car.increment_odometer(100)
my_new_car.read_odometer()
my_new_car.increment_odometer(100)
my_new_car.read_odometer()


